//
// Created by jetkey on 18-8-10.
//

#include <jni.h>

#include "testsuit_framework.h"

static jstring JNICALL getUrl(JNIEnv *env, jobject jobj){
return env->NewStringUTF("hello!Im C!");
}


static const JNINativeMethod gMethods[] = {
        {"getUrl", "()Ljava/lang/String;", (void *)getUrl},
        {"getTestCount", "()I", (void *)getTestCount},
        {"getTestName", "(I)Ljava/lang/String;", (void *)getTestName},
        {"runTest", "(I)I", (void *)runTest},
};


JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved){
    JNIEnv *env; //注册时在JNIEnv中实现的，所以必须首先获取它
    jint result = -1;
    if(vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) //从JavaVM获取JNIEnv，一般使用1.4的版本
        return -1;
    jclass myClass = env->FindClass("com/imi/sdk/jnitest/MainActivity");
    if(myClass == NULL) {
        return -1;
    }
    if(env->RegisterNatives(myClass,gMethods,sizeof(gMethods)/sizeof(gMethods[0]))!=JNI_OK) {
        return -1;
    }
//    printf("--------JNI_OnLoad-----");
    return JNI_VERSION_1_4; //这里很重要，必须返回版本，否则加载会失败。
}

